Uec3.addAutoPurchaseWindowCreator = Ext.extend(PurchaseWindowCreator, {
	id : 'addAutoPurchaseCreator',
	
	getPurchaseItemGrid : function() {
		
		var purchase_item_colName = this.creator.getPurchaseItemColName.bind(this)();
		
		// 创建grid，装载明细数据
		return new Ext.grid.EditorGridPanel({
//			title : '采购订单明细',
			style : {padding : '2px'},
			height : 150,
			clicksToEdit : 1,
			colModel : purchase_item_colName,
//					autoScroll : true,
			store : this.purchase_item_store
		});

	},
	getPanel : function(main_win, initParams) {
		
		this.setAllHidden.bind(main_win)();
		
		this.setAllCmb.bind(main_win)();
		
		main_win.purchase_item_record = this.getPurchaseItemRecord.bind(main_win)();
		
		main_win.purchase_item_store = this.getPurchaseItemStore.bind(main_win)();
		
//		alert('');

		main_win.partner_combox = this.getPartnerCombox.bind(main_win)();

		main_win.quotation_item_store = this.getQuotationItemStore.bind(main_win)();

		main_win.quotation_item_grid = this.getQuotationItemGrid.bind(main_win)();
		
		main_win.quotation_form_item1 = this.getQuotationFormItem1.bind(main_win)();
		
		main_win.purchase_item_grid = this.getPurchaseItemGrid.bind(main_win)();
		
		main_win.address_combox = this.getAddressCombox.bind(main_win)();
		
		main_win.purchase_panel = this.getPurchasePanel.bind(main_win)();
		
		main_win.quotation_panel = this.getQuotationPanel.bind(main_win)();
		
		/**
		 * 选中报价记录将其添加到采购记录中
		 * 
		 * @param {}
		 *            id
		 */
		function quotationClickToAdd(record) {

			if (!this.creator.validatePur.bind(this, record.data.code + record.data.source)()) {
				return;
			}
	
			var purRecord = this.creator.getPurRecord.bind(this, record)();

			var index = this.purchase_item_store.getCount();
		
			this.purchase_item_store.insert(index, purRecord);

		}

		function bindBuyItemEvent() {
			var recs = this.quotation_item_store.getRange();
			var ref = this;
			Ext.each(recs, function(rec) {
						rec.main_win = ref;
						var obj = Ext.get(QUO_BUY_REOCRD_ID + rec.data.id + rec.main_win.versionCode);
						obj.on('click', function() {
									quotationClickToAdd.bind(this.main_win, this)();
								}.bind(rec));
					});
		}

		Ext.util.Observable.capture(main_win.quotation_item_store, function(e) {
					if (e == 'load') {
						bindBuyItemEvent.bind(this)();
					}
				}.bind(main_win));

		
		this.addEventToPurItemGrid.bind(main_win)();
		
		// 总布局面板
		main_win.join_panel = new Ext.Panel({
			// labelAlign : 'right',
			frame : true,
			height : 600,
//					autoWidth : true,
			autoScroll : true,
			items : [main_win.quotation_panel, main_win.purchase_panel]
		});

		main_win.join_panel.main_win = main_win;

		

		return main_win.join_panel;
	}

});
